﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HouseManager.BLL;

namespace HouseManager
{
    public partial class Default : System.Web.UI.Page
    {
        MangerBLL mangerBLL = new MangerBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //调用方法给控件绑定数据源
                var list = mangerBLL.GetList();
                GridView1.DataSource = list;
                GridView1.DataBind();
            }
        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            //跳转到添加页面
            Response.Redirect("Add.aspx");
        }
        //查询
        protected void btnSelectName_Click(object sender, EventArgs e)
        {
            //声明变量接收用户输入的值.
            string name=txtName.Text;
            //调用方法给控件重新绑定数据
            GridView1.DataSource = mangerBLL.GetListName(name);
            GridView1.DataBind();
        }
    }
}